{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class=""><a href="{:url('admin/generalwarehouse/index')}">总仓管理</a></li>
            <li class="layui-this">添加货存</li>
            <li class=""><a href="{:url('admin/generalwarehouse/inside')}">新增内仓发货</a></li>
            <li class=""><a href="{:url('admin/generalwarehouse/external')}">新增外仓发货</a></li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                <form class="layui-form form-container" action="{:url('admin/generalwarehouse/save')}" method="post">

                    <div class="layui-form-item" id="products">
                        <label class="layui-form-label">所属分类</label>
                        <div class="layui-input-block">
                            <select name="pid" lay-filter="test">
                                <option value="0">请选择分类</option>
                                {foreach name="category_level_list" item="vo"}
                                <option value="{$vo.id}" >{neq name="vo.level" value="1"}|{php}for($i=1;$i<$vo['level'];$i++){echo ' ----';}{/php}{/neq} {$vo.name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item product">
                    <label class="layui-form-label">所属产品</label>
                        <div class="layui-input-block">
                            <select name="cid">
                                <option value="0">请选择产品</option>
                                {foreach name="products_level_list" item="v"}
                                <option value="{$v.id}">{$v.name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">进货货存</label>
                        <div class="layui-input-block">
                            <input type="text" name="buy" value="0" placeholder="（选填）请输入进货数量" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">进货时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="publish_time" value="{:date('Y-m-d H:i:s')}" class="layui-input datetime">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">备注</label>
                        <div class="layui-input-block">
                            <textarea name="remark" placeholder="（选填）请输入备注" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" type="submit">保存</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script type="text/javascript" charset="utf-8" src="__JS__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__JS__/ueditor/ueditor.all.min.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="__JS__/ueditor/lang/zh-cn/zh-cn.js"></script>

{/block}
{block name="script"}
<script type="text/javascript">
//    var ue = UE.getEditor('content');  // 使用所有功能
//    自定义修改传入参数修改设置
    var ue = UE.getEditor('content',{
        mergeEmptyline: true, //合并空行
        removeClass: true, //去掉冗余的class
        removeEmptyline: false, //去掉空行
        imageBlockLine: 'left', //图片的浮动方式，独占一行剧中，左右浮动，默认: center，left，right，none 去掉这个属性表示不执行排版
        removeEmptyNode: true  , // 去掉空节点
       // toolbars:[['fullscreen','source','undo','redo','bold']],
        autoHeightEnabled: true,
        autoFloatEnabled:true
    })
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
  //  var ue = UE.getEditor('content');
</script>
<script type="text/javascript">
$('.product').hide();
form.on('select(test)', function(data){
  console.log(data);
  $(".product").show();
  $.ajax({
    'url':"son",
    'data':"pid="+data.value,
    'type':'post',
    'dataType':'json',
    'success':function(response){
        $('.product div div dd').hide();
        var son = $('.product div div dd');
        var length = son.length;
        $.each(response,function(i,n){
            for(var i = 0;i < length;i++){
                var value = son.eq(i).attr('lay-value');
                // console.log(value);
                if(value == n.id){
                    $('.product div div dd').eq(i).show();
                }
            }
            console.log(n);
        });
    }

  });
});
</script>

{/block}